#coding=utf-8
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QMenuBar, QAction, qApp
from PyQt5.QtGui import QIcon

# 菜单栏
class Example2(QMainWindow):
    def __init__(self):
        super().__init__()
        self.initUI()
        pass

    def initUI(self):
        self.statusBar() #创建一个空的状态栏
        menubar = self.menuBar()
        menubar.setNativeMenuBar(False)
        fileMenu = menubar.addMenu('File')

        #给menu创建一个Action
        exitAction = QAction(QIcon('exit.png'), 'Exit', self)
        exitAction.setShortcut('Ctr+Q')
        exitAction.setStatusTip('Exit Application')
        exitAction.triggered.connect(qApp.quit)

        #将这个Action添加到fileMenu上
        fileMenu.addAction(exitAction)

        self.setWindowTitle('QMainWindow的菜单栏的显示')
        self.setGeometry(200, 150, 1000, 600)
        self.show()
        pass

def main2():
    app = QApplication(sys.argv)
    example = Example2()
    sys.exit(app.exec_())
    pass

if __name__ == '__main__':
    main2()
